<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>DEMO</title>
	<link rel="stylesheet" href="../../css/bootstrap.min.css" />
	<link rel="stylesheet" href="../../css/common.css" />
	<link rel="stylesheet" href="../../css/welcome.css" />
	<link rel="stylesheet" href="../../css/validationEngine.jquery.css" /><!--表单验证css-->
	<script type="text/javascript" src="../../js/jquery-1.8.3.min.js"></script>

</head>
<body>
<div class="main_content create_site">
	<div class="col-xs-12 col-sm-12 div_bordered">
		<div class="panel panel-default">
			<div class="jkbg_title_boxa" style="border: 0px">
				<a href="bed_manage.html" class="btn_blue pull-right mr15" >返回</a>
				<h4>床位配置</h4>
				<div class="divider" style="margin: 0 25px;width: 100%;"></div>
			</div>
			<div class="site_block " style="padding: 0px 15px;">
				<div class="well_head">
					<div class="line"></div>
					<span class="pull-left" >快速生成</span>
					<!--<button type="button" class="btn btn-sm pull-right border-red">保存成功</button>-->
				</div>
				<div class="panel-body">
					<form class="form-horizontal check_form" role="form" id="batchCreateForm">
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">楼栋名称：</label>
							<div class="col-sm-10 ml150">
								<input type="text" name="buildingName" class="form-control inline validate[required, minSize[1], maxSize[10]]" style="width: 185px;" id=""  placeholder="请输入楼栋名称" >
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">楼层数：</label>
							<div class="col-sm-10 ml150">
								一共&nbsp;  <input type="text" name="floorNumber" input-type="date" class="form-control  input150 validate[required,custom[integer],min[1],max[60]]" id=""  placeholder=""><em>&nbsp;层</em>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">房间数：</label>
							<div class="col-sm-10 ml150">
								每层&nbsp;  <input type="text" name="roomNumberPerFloor" input-type="date" class="form-control  input150 validate[required,custom[integer],min[1],max[60]]" id=""  placeholder=""><em>&nbsp;间</em>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">床位数：</label>
							<div class="col-sm-10 ml150">
								每间&nbsp;  <input type="text" name="bedNumberPerRoom" input-type="date" class="form-control  input150 validate[required,custom[integer],min[1],max[12]]" id=""  placeholder=""><em>&nbsp;床</em>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">床位费：</label>
							<div class="col-sm-10 ml150">
								<div class="btn-group mr15">
									<button type="button" class="btn btn-default dropdown-text" style="width: 160px;">请选择</button>
									<button type="button" class="btn btn-default dropdown-toggle">
										<span class="caret"></span>
										<span class="sr-only">切换下拉菜单</span>
									</button>
									<ul class="dropdown-menu">
										<c:forEach items="${costItemHistoryList}" var="costItemHistory">
											<li><a href="javascript:;" onclick="priceGet(this,'${costItemHistory.price}','${costItemHistory.costItemId}')">双人间</a></li>
										</c:forEach>
									</ul>
									<input name="bedFeeType" type="hidden" value=""/>
								</div>
								<div class="inline pl20">
									每床&nbsp;<input type="text" readonly="readonly" class="form-control  input150 mr0" id=""  placeholder=""><em>&nbsp;元/月</em>
								</div>
							</div>
						</div>
						<div class="form-group text-center mt30" >
							<button type="button" class="btn btn_next mt30" onclick="batchCreate(this)">快速生成</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
</body>

<script type="text/javascript" src="../../js/common.js" ></script>
<!--表单验证 s-->
<script type="text/javascript" src="../../js/jquery.validationEngine-zh_CN.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/jquery.validationEngine.js" charset="utf-8"></script>
<!--表单验证 e-->
<script type="text/javascript">
    $("#batchCreateForm").validationEngine({promptPosition: "inline"});
    //设置床位价格
    function priceGet(obj, price, costItemId){
        $(obj).parents("ul").next().val(costItemId);
        $(obj).parents(".btn-group").next().find(":text").val(price);
    }
    function batchCreate(tag){
        $(tag).prop("disabled",true);
        if(!$("#batchCreateForm").validationEngine("validate")) {
            zhyAlert("请按照红色错误提示正确填写表单，重新提交");
            $(tag).prop("disabled",false);
            return ;
        }

        if ($("input[name='bedFeeType']").val() == "") {
            zhyAlert("床位价格必须选择！");
            $(tag).prop("disabled",false);
            return;
        }

        $.ajax({
            type:"post",
            url:"${ctx}/cm/bedconfig/batch_generate.action",
            dataType:"json",
            data:$("#batchCreateForm").serialize(),
            success:function(result){
                if(result.resultCode=="SUCC"){
                    window.location.href="${ctx}/cm/bedconfig/bed_manager.action";
                }else{
                    $(tag).prop("disabled",false);
                    zhyAlert(result.failureMessage);
                }
            }
        });
    }
</script>
</html>